<?php 

/**
 * 短信提供商
 * @author liuyang
 * @since 20160417
 * @version 2.0
 */
namespace Common\Provider;  
use Common\Util\ConfigUtils; 
use Common\Util\LogUtils;
class SmsProvider{  
     
    /**
     * 分发
     * @param unknown $phone
     * @return number
     */
    public static function dispatch($phone,$content) {
        $rstcode=0;
        if(strlen($phone)==11){
            $phoneSuffix=substr($phone, 0,3); 
            $list = ConfigUtils::getConfig("SMS_SERVICE_LIST");
            $serviceClass=""; 
            foreach ($list as $key=>$val){
                if($val==0||in_array($phoneSuffix, $val)){
                    $serviceClass = $key; 
                    break;
                } 
            }     
           $smsClass = new \ReflectionClass($serviceClass); 
           $smsService=$smsClass->newInstanceArgs();
           // $smsService = new Sms189Service($phone);    
            $rstcode = $smsService->sendInfo($phone,$content); 
        }
        LogUtils::write($phone.$content."uni_rand_code:".$rstcode);
        return $rstcode;
    }
}

?>